package com.library.service.impl;

import com.library.entity.User;
import com.library.mapper.UserMapper;
import com.library.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    
    @Autowired
    private UserMapper userMapper;
    
    @Override
    public User login(String username, String password) {
        return userMapper.findByUsernameAndPassword(username, password);
    }
    
    @Override
    public List<User> findAllUsers() {
        return userMapper.findAll();
    }
    
    @Override
    public boolean addUser(User user) {
        // 这里可以添加一些逻辑，比如检查用户名是否已存在
        return userMapper.insert(user) > 0;
    }
    
    @Override
    public boolean updateUser(User user) {
        return userMapper.update(user) > 0;
    }
    
    @Override
    public boolean deleteUser(Integer id) {
        return userMapper.delete(id) > 0;
    }
} 